package com.dj.mingkong.portal.biz.repository.database.music;


import com.dj.mingkong.common.infrastructure.base.dto.query.QueryVo;
import com.dj.mingkong.common.infrastructure.base.repository.BaseDatabaseRepository;
import com.dj.mingkong.common.infrastructure.eo.database.music.BoxCollectEo;
import com.dj.mingkong.portal.biz.repository.database.music.mapper.BoxCollectMapper;
import org.springframework.stereotype.Repository;

import java.util.Optional;

/**
 * 音乐盒收藏Repository
 *
 * @author zenglonghui
 * @date: 2022/5/17 19:14
 */
@Repository
public class BoxCollectRepository extends BaseDatabaseRepository<BoxCollectMapper, BoxCollectEo, QueryVo> {
    public Optional<BoxCollectEo> oneOptByUserIdAndBoxId(Long userId, Long boxId) {
        return lambdaQuery()
                .eq(BoxCollectEo::getUserId, userId)
                .eq(BoxCollectEo::getBoxId, boxId)
                .oneOpt();
    }

    public boolean deleteByBoxId(Long boxId) {
        return lambdaUpdate().eq(BoxCollectEo::getBoxId, boxId).remove();
    }
}
